package data;

import java.util.ArrayList;
import java.util.List;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement;

@XmlRootElement(name = "cal")
public class Cal implements java.io.Serializable{

    @XmlElementWrapper(name = "tasks")
    @XmlElement(name = "task")
    public List<Task> tasks;
	
    @XmlElementWrapper(name = "users")
    @XmlElement(name = "user")
    public List<User> users;	

    public void delete(String myTask){
    	for(Task e : tasks){
    		if(e.id.equalsIgnoreCase(myTask)){
    			tasks.remove(e);
    		}
    		
    	}
    	
    }
    
    public List<Task> get(String attendant){
    	List<Task> attsList = new ArrayList<Task>();
    	for(Task e : tasks){
    		for (User u : e.attendant){
    			if(u.id.equalsIgnoreCase(attendant)){
    				attsList.add(e);
    			}
    		}
    	}
    	return attsList;
       }
}
